runWithCurrentInvoke
@h4ad/serverless-adapter > runWithCurrentInvoke
(function) runWithCurrentInvoke
Run a callback with the event created by the serverless trigger and the context created by the serverless environment bound to the current async invocation scope.
Signature:
export declare function runWithCurrentInvoke<TEvent = any, TContext = any, TReturn = unknown>(\{ event, context }: CurrentInvoke<TEvent, TContext>, callback: () => TReturn): TReturn;
Parameters
Parameter | Type | Description |
|---|---|---|
{ event, context } | CurrentInvoke <TEvent, TContext> | |
callback | () => TReturn | The callback to run inside the current invocation scope |
Returns:
TReturn
Remarks
Use this when implementing a custom handler that forwards requests into framework code. The built-in handlers call it before creating the resolver and forwarding the request, so getCurrentInvoke() can read the right invoke data throughout the framework's async work.